package mysql

import (
	"fmt"
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
	config2 "zgyzk3/config"
)

var DB *gorm.DB

func MysqlInit() {
	var err error
	DB, err = gorm.Open(config2.Data.Mysql.Dialect, config2.Data.Mysql.Dsn)
	if err != nil {
		panic(err)
	} else {
		fmt.Println("数据库连接成功")
	}
	// 自动迁移
	DB.AutoMigrate(&User{})

}
